<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>随机颜色</title>
    <style>
        *{
            border: 0;
            margin: 0;
            padding: 0;
        }
        
        div {
            width: 100vw;
            height: 100vh;
            text-align: center;
            line-height: 100vh;
            color: #fff;
            font-size: 36px
        }
    </style>
</head>

<body>
    <script>
        let randomColorArray = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f']

        let randomColor = '#'

        for (let i = 0; i < 6; i++) {
            randomColor += randomColorArray[Math.floor(Math.random() * randomColorArray.length)]
        }

        // 转换为大写
        randomColor = randomColor.toUpperCase()

        document.write(`
            <div style="background-color: ${randomColor};">颜色：${randomColor}</div>
        `)
    </script>
</body>

</html>